home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / dev / gg / gengetopt-2.6.lha / gengetopt-2.6 / src / strdup.c < prev    next >
C/C++ Source or Header  |  2001-12-17  |  272b  |  18 lines

  1. /* strdup.c replacement of strdup, which is not standard */
  2.  
  3. #include <stdlib.h>
  4. #include <string.h>
  5.  
  6. char *
  7. strdup (const char *s)
  8. {
  9.   char *result = (char*)malloc(strlen(s) + 1);
  10.  
  11.   if (result == (char*)0)
  12.     return (char*)0;
  13.  
  14.   strcpy(result, s);
  15.  
  16.   return result;
  17.